package com.team.employment.web.admin.controller.position;

import com.team.employment.common.result.Result;
import com.team.employment.model.entity.PositionLevel2;
import com.team.employment.model.entity.PositionLevel3;
import com.team.employment.web.admin.service.PositionLevel3Service;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "三级级职位层级管理")
@RestController
@RequestMapping("/admin/positionThree")
public class positionLevel3Controller {

    @Autowired
    private PositionLevel3Service positionLevel3Service;

    @Operation(summary = "根据二级职位id查询三级职位列表")
    @GetMapping("getPositionLevel3/{id}")
    public Result<List<PositionLevel3>> getPositionLevel3(@PathVariable Integer id){
        List<PositionLevel3> list = positionLevel3Service.getByLevel2Id(id);
        return Result.ok(list);
    }


    @Operation(summary = "保存或更新三级级职位信息")
    @PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody PositionLevel3 positionLevel3) {
        positionLevel3Service.saveOrUpdate(positionLevel3);
        return Result.ok();
    }

    @Operation(summary = "删除三级级职位信息")
    @DeleteMapping("removeById/{id}")
    public Result removeById(@PathVariable Long id ) {
        //deleteCheck.DeleteCheckSuccessful(positionLevel3Service,id);
        positionLevel3Service.removeById(id);
        return Result.ok();
    }

}
